package com.alcatel_lucent.osp.utils;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;

import java.util.List;

/**
 * Created by guoshunw on 2014/10/8.
 */
public class CommonUtils {

    /**
     * If any str match any pattern in the list
     *
     * @param str      str used for match
     * @param patterns the pattern list
     * @return true if atr match any pattern in the list or false
     */
    public static boolean anyMatch(final String str, List<String> patterns) {
        return CollectionUtils.exists(patterns, new Predicate() {
            @Override
            public boolean evaluate(Object object) {
                return str.matches((String) object);
            }
        });
    }

}
